package com.css.bjdt_report.report.entity;

import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.View;

import com.css.bjdt_report.util.ReportConstant;

import lombok.Data;

@Data
@View("VIEW_RPT_TEMPLATE_CONDITION")
public class ViewRptTemplateCondition extends RptTemplateCondition {
	@Column("TABLE_NAME")
	private String setName;
	@Column("CHINESE_NAME")
	private String chineseName;
	@Column("ITEM_ID")
	private String itemId;
	@Column("ITEM_NAME")
	private String itemName;
	@Column("ITEM_CHINESE_NAME")
	private String itemChineseName;
	@Column("VAL_TYPE")
	private int valType;

	private String comboTypeName;

	private String logicOperatorName;

	private String relaOperatorName;

	private String realConditionVal;

	public String getRealConditionVal() {
		realConditionVal = super.getConditionVal();
		if (realConditionVal != null) {
			switch (this.getValType()) {
			case ReportConstant.STRING:
				if("7".equals(super.getRelaOperator())){
					return "'%" + realConditionVal + "%'";
				}else if("8".equals(super.getRelaOperator())){
					return "'" + realConditionVal + "%'";
				}else if("9".equals(super.getRelaOperator())){
					return "'%" + realConditionVal + "'";
				}else{
					return "'" + realConditionVal + "'";
				}
			case ReportConstant.NUMBER:
				return realConditionVal;
			case ReportConstant.DATE:
				return ReportConstant.TO_DATE_FUN.replace(ReportConstant.CONDITION_VAL, realConditionVal);
			default:
				return realConditionVal;
			}
		}
		return realConditionVal;
	}

	public String getComboTypeName() {
		comboTypeName = super.getComboType();
		if (comboTypeName != null) {
			switch (comboTypeName) {
			case "1":
				return "(";
			case "2":
				return ")";
			default:
				return "";
			}
		}
		return "";
	}

	public String getLogicOperatorName() {
		logicOperatorName = super.getLogicOperator();
		if (logicOperatorName != null) {
			switch (logicOperatorName) {
			case "1":
				return "and";
			case "2":
				return "or";
			default:
				return "";
			}
		}
		return "";
	}

	public String getRelaOperatorName() {
		relaOperatorName = super.getRelaOperator();
		if (relaOperatorName != null) {
			switch (relaOperatorName) {
			case "1":
				return "=";
			case "2":
				return ">=";
			case "3":
				return "<=";
			case "4":
				return ">";
			case "5":
				return "<";
			case "6":
				return "!=";
			case "7":
				return "like";
			case "8":
				return "like";
			case "9":
				return "like";
			default:
				return "=";
			}
		}
		return "=";
	}

	//页面展示用
	private String jspComboTypeShow;

	private String jspLogicOperatorShow;

	private String jspRelaOperatorShow;
}
